//
//  HTMapViewController.m
//  HeartTravel
//
//  Created by lanou on 15/11/3.
//  Copyright © 2015年 陈文杰. All rights reserved.
//

#import "HTMapViewController.h"
#import "MapCustom.h"
@interface HTMapViewController ()

@end

@implementation HTMapViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.topView.backgroundColor = [UIColor colorWithRed:0.351 green:0.359 blue:0.350 alpha:1.000];
    [self.leftButton setBackgroundImage:[UIImage imageNamed:@"返回"] forState:(UIControlStateNormal)];
    [self.leftButton addTarget:self action:@selector(didClickBackRootViewController) forControlEvents:(UIControlEventTouchUpInside)];
    self.titleLabel.text = self.titleName;
    map = [[MKMapView alloc]initWithFrame:CGRectMake(0, 70, SCREEN_WIDTH, SCREEN_HEIGHT - 70)];
    map.showsUserLocation = YES;
    map.mapType = MKMapTypeStandard;
    [self.view addSubview:map];
    CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(self.lat, self.lng);
    float zoomLevel = 0.02;
    MKCoordinateRegion region = MKCoordinateRegionMake(coords, MKCoordinateSpanMake(zoomLevel, zoomLevel));
    [map setRegion:[map regionThatFits:region] animated:YES];
    
    [self createAnnotationWithCoords:coords];
}
// 新建个方法添加大头针
- (void)createAnnotationWithCoords:(CLLocationCoordinate2D) coords{
    MapCustom *mapCustom = [[MapCustom alloc]initWithCoordinate:coords];
    mapCustom.tTitle = self.titleName;
    [map addAnnotation:mapCustom];
}

- (void)didClickBackRootViewController{
    [self.navigationController popViewControllerAnimated:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
